<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--服务商管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <script src="__STATIC_URL__/static/jquery/2.2.1/jquery.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/layer/layer.js"></script>
</head>
<style>
    .pageBar {
        position: relative;
        margin: 10px 0;
    }

    .tab {
        border-bottom: 1px solid #eaedf0;
        margin: 0;
    }

    .tab .tabtitle {
        font-size: 18px;
        padding: 12px 0 !important;
    }

    .tab a {
        padding: 12px 18px;
        border-bottom: 1px solid transparent;
        margin-bottom: -2px;
        font-size: 14px;
        cursor: pointer;
    }
</style>
<body>
{include file='public/header'/}
<section>
    <!------------------导航-------------------------->
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>当前位置是:</li>
                <li><a href="{:url('momach/momachlist')}">商户管理</a></li>
                <li><a href="javascript:history.back();">商户进件</a></li>
                <li class="active" style="color: #02b87f;">微信开发配置</li>
            </ul>
        </div>
        <div class="mgl15 mgr15">
            <form class="form-horizontal adminex-form" action="" method="post" id="mach" name="form"
                  enctype="multipart/form-data">
                <input type="hidden" id="wid" value="{$id}">
                <div class="pageBar">
                    <div class="tab">
                        <a class="tabtitle">推荐关注</a>
                    </div>
                </div>
                <div class="form-group" id="">
                    <label class="col-sm-2 col-sm-2 control-label" style="text-align:left;">关注公众号</label>
                    <div class="col-sm-10">

                        <label class="control-label" style="font-size:15px;color:#a7a3a3;">特约商户下每个subappid都可配置相同或不同的推荐关注公众号</label>

                    </div>

                    <label class="col-sm-2 col-sm-2 control-label" style="text-align:left;">已配置</label>
                    <div class="col-sm-10">

                        <label class="control-label" style="font-size:15px;color:#a7a3a3;" id="pubnumberappid"></label>

                    </div>
                    <label class="col-sm-2 col-sm-2"></label>
                    <div class="col-sm-10">
                        <button type="button" onclick="addwx()" class="btn btn-primary"
                                style=" background: #3092ff;border: 1px solid #218aff;">添加
                        </button>

                    </div>
                </div>
                <div class="pageBar">
                    <div class="tab">
                        <a class="tabtitle">支付授权目录</a>
                    </div>
                </div>
                <div class="form-group" id="">
                    <label class="col-sm-2 col-sm-2 control-label" style="text-align:left;">支付授权目录</label>
                    <div class="col-sm-10">

                        <label class="control-label" style="font-size:15px;color:#a7a3a3;">支付相关域名</label>

                    </div>
                    <label class="col-sm-2 col-sm-2 control-label" style="text-align:left;">已配置</label>
                    <div class="col-sm-10">

                        <label class="control-label" style="font-size:15px;color:#a7a3a3;" id="pubnumberauth"></label>

                    </div>
                    <label class="col-sm-2 col-sm-2"></label>
                    <div class="col-sm-10">
                        <button type="button" onclick="addurl()" class="btn btn-primary"
                                style=" background: #3092ff;border: 1px solid #218aff;">添加
                        </button>

                    </div>
                </div>

            </form>

        </div>
        {include file='public/footer'/}
    </div>
</section>

<!-- 添加关注公众号 -->
<div class="modal fade" id="xgbangding" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="xgbangdingLabel">推荐关注 | 添加关注公众号</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="xgbangdingform">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">*特约商户sub_appid：</label>
                        <div class="col-sm-8">
                            <input type="text" id="wechatPubNumAppid" class="form-control" placeholder=""/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">*关注公众号appid：</label>
                        <div class="col-sm-8">
                            <input type="text" id="wechatPubNum" class="form-control" placeholder=""/>
                        </div>
                    </div>
                    <div class="form-group" style="color:red;text-align:center;">只允许添加，不允许修改，请确认无误后点击确定！</div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="seteconfig()">添加</button>
            </div>
        </div>
    </div>
</div>
<!-- 添加关注公众号 -->
<div class="modal fade" id="addgzh" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="xgbangdingLabel1">支付权限 | 添加支付授权目录</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="xgbangdingform1">
                    <div class="form-group"><label class="col-sm-12 control-label" style="text-align:left;">JS
                        API支付授权目录：</label>
                    </div>
                    <div class="form-group">

                        <div class="col-sm-4">
                            <select class="form-control" style="" id="is_ssl" name="alipayCateCode">
                                <option value="https://">https://</option>
                                <option value="http://">http://</option>
                            </select>
                        </div>
                        <div class="col-sm-8">
                            <input type="text" id="wechatPubNumAuth" class="form-control" placeholder=""/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div style="font-size:13px;color:#a7a3a3;text-align:left;text-indent:65px;">
                            <p>1.所有使用JS API方式发起支付请求的链接地址，都必须在支付授权目录之下</p>
                            <p>2.最多设置4个支付授权目录, 且域名必须通过ICP备案</p>
                            <p>3.头部要包含http或https，须细化到二级或三级目录，以左斜杠“/”结尾</p>
                            <p>4.修改会影响线上交易，距正式生效有十分钟左右延迟，建议你避开交易高峰时间修改</p></div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="seteconfig()">添加</button>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    function addwx() {
        $("#xgbangding").modal("show");
    }

    function addurl() {
        $("#addgzh").modal("show");
    }
</script>
<script>
    function seteconfig() {
        var id = $('#wid').val();
        $.ajax({
            url: "{:url('momach/wxmachtobank')}",
            data: {
                id: id,
                method: "setwxconfig",
                wechatPubNumAppid: $('#wechatPubNumAppid').val(),
                wechatPubNumAuth: $('#is_ssl').val() + $('#wechatPubNumAuth').val(),
                wechatPubNum: $('#wechatPubNum').val(),
            },
            dataType: "json",
            type: "post",
            success: function (res) {
                var url = res;
                if (res.result_code == "SUCCESS") {
                    if (res.info !== "") {

                        layer.msg(res.result_msg);
                        setTimeout(function(){
                            window.location.reload()
                        },1500)


                    }

                } else {

                    layer.msg(res.result_msg);
                }
            }
        })
    }

    $(function () {
        var id = $('#wid').val();
        $.ajax({
            url: "{:url('momach/wxmachtobank')}",
            data: {
                id: id,
                method: "getwxconfig"
            },
            dataType: "json",
            type: "post",
            success: function (res) {
                console.log(res);
                var url = res;
                if (res.result_code == "SUCCESS") {
                    if (res.info !== "") {
                        pubnumberappid = "";
                        if (res.info.wechatPubNumAppid1 !== "") {
                            pubnumberappid += "<p>"+res.info.wechatPubNumAppid1+"</p>"
                        }
                        if (res.info.wechatPubNumAppid2 !== "") {
                            pubnumberappid += "<p>"+res.info.wechatPubNumAppid2+"</p>"
                        }
                        if (res.info.wechatPubNumAppid3 !== "") {
                            pubnumberappid += "<p>"+res.info.wechatPubNumAppid3+"</p>"
                        }
                        if (res.info.wechatPubNumAppid4 !== "") {
                            pubnumberappid += "<p>"+res.info.wechatPubNumAppid4+"</p>"
                        }
                        if (res.info.wechatPubNumAppid5 !== "") {
                            pubnumberappid += "<p>"+res.info.wechatPubNumAppid5+"</p>"
                        }
                        $('#pubnumberappid').html(pubnumberappid);
                        pubnumberauth = "";
                        if (res.info.wechatPubNumAuth1 !== "") {
                            pubnumberauth += "<p>"+res.info.wechatPubNumAuth1+"</p>"
                        }
                        if (res.info.wechatPubNumAuth2 !== "") {
                            pubnumberauth += "<p>"+res.info.wechatPubNumAuth2+"</p>"
                        }
                        if (res.info.wechatPubNumAuth3 !== "") {
                            pubnumberauth += "<p>"+res.info.wechatPubNumAuth3+"</p>"
                        }
                        if (res.info.wechatPubNumAuth4 !== "") {
                            pubnumberauth += "<p>"+res.info.wechatPubNumAuth4+"</p>"
                        }
                        if (res.info.wechatPubNumAuth5 !== "") {
                            pubnumberauth += "<p>"+res.info.wechatPubNumAuth5+"</p>"
                        }
                        $('#pubnumberauth').html(pubnumberauth);
                    }

                } else {

                    layer.msg(res.result_msg);
                }
                // window.location.href=res;
            }
        })
    })
</script>
</html>